<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="类型：1-普通职位，2-灵活用工，3-共享用工">
              <j-dict-select-tag placeholder="请选择类型：1-普通职位，2-灵活用工，3-共享用工" v-model="queryParam.positionType" dictCode="position_type"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="是否兼职：1-兼职，0-全职">
              <j-dict-select-tag placeholder="请选择是否兼职：1-兼职，0-全职" v-model="queryParam.ifParttime" dictCode="if_parttime"/>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="职位名称">
                <a-input placeholder="请输入职位名称" v-model="queryParam.postName"></a-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('岗位列表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <rms-company-position-modal ref="modalForm" @ok="modalFormOk"></rms-company-position-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import RmsCompanyPositionModal from './modules/RmsCompanyPositionModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'RmsCompanyPositionList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      RmsCompanyPositionModal
    },
    data () {
      return {
        description: '岗位列表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'类型：1-普通职位，2-灵活用工，3-共享用工',
            align:"center",
            dataIndex: 'positionType_dictText'
          },
          {
            title:'是否兼职：1-兼职，0-全职',
            align:"center",
            dataIndex: 'ifParttime_dictText'
          },
          {
            title:'公司ID',
            align:"center",
            dataIndex: 'companyId'
          },
          {
            title:'名称ID',
            align:"center",
            dataIndex: 'postId'
          },
          {
            title:'职位名称',
            align:"center",
            dataIndex: 'postName'
          },
          {
            title:'职位描述',
            align:"center",
            dataIndex: 'descr'
          },
          {
            title:'地址名称',
            align:"center",
            dataIndex: 'addressName'
          },
          {
            title:'门牌号',
            align:"center",
            dataIndex: 'addressHouse'
          },
          {
            title:'工作地点',
            align:"center",
            dataIndex: 'address'
          },
          {
            title:'地点经度',
            align:"center",
            dataIndex: 'longitude'
          },
          {
            title:'地点纬度',
            align:"center",
            dataIndex: 'latitude'
          },
          {
            title:'经验要求',
            align:"center",
            dataIndex: 'expRequire'
          },
          {
            title:'最低学历',
            align:"center",
            dataIndex: 'minEducation_dictText'
          },
          {
            title:'薪资范围',
            align:"center",
            dataIndex: 'salaryLow'
          },
          {
            title:'薪资范围',
            align:"center",
            dataIndex: 'salaryUp'
          },
          {
            title:'薪资月份',
            align:"center",
            dataIndex: 'salaryMonth'
          },
          {
            title:'薪资范围',
            align:"center",
            dataIndex: 'salary'
          },
          {
            title:'薪资单位，兼职，元/时，元/天，元/周，元/月',
            align:"center",
            dataIndex: 'unit'
          },
          {
            title:'兼职，薪资单价',
            align:"center",
            dataIndex: 'unitMoney'
          },
          {
            title:'奖金绩效',
            align:"center",
            dataIndex: 'bonus'
          },
          {
            title:'结算方式，兼职，日结、周结、月结、完工结',
            align:"center",
            dataIndex: 'settlementType'
          },
          {
            title:'招聘人数',
            align:"center",
            dataIndex: 'recruitsNumber'
          },
          {
            title:'兼职工作日',
            align:"center",
            dataIndex: 'partDate'
          },
          {
            title:'兼职时间',
            align:"center",
            dataIndex: 'partTime'
          },
          {
            title:'联系电话',
            align:"center",
            dataIndex: 'phone'
          },
          {
            title:'技能要求',
            align:"center",
            dataIndex: 'skill'
          },
          {
            title:'开始日期',
            align:"center",
            dataIndex: 'startDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'结束日期',
            align:"center",
            dataIndex: 'endDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'工作天数',
            align:"center",
            dataIndex: 'workDays'
          },
          {
            title:'共享人数',
            align:"center",
            dataIndex: 'shareNumber'
          },
          {
            title:'分享佣金',
            align:"center",
            dataIndex: 'shareMoney'
          },
          {
            title:'浏览数量',
            align:"center",
            dataIndex: 'browseNumber'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remark'
          },
          {
            title:'县级城市名称',
            align:"center",
            dataIndex: 'city'
          },
          {
            title:'县级城市编码',
            align:"center",
            dataIndex: 'citycode'
          },
          {
            title:'市级城市名称',
            align:"center",
            dataIndex: 'pcity'
          },
          {
            title:'市级城市编码',
            align:"center",
            dataIndex: 'pcitycode'
          },
          {
            title:'tenantId',
            align:"center",
            dataIndex: 'tenantId'
          },
          {
            title:'删除状态(0-正常,1-已删除)',
            align:"center",
            dataIndex: 'delFlag'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'status'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/rms/rmsCompanyPosition/list",
          delete: "/rms/rmsCompanyPosition/delete",
          deleteBatch: "/rms/rmsCompanyPosition/deleteBatch",
          exportXlsUrl: "/rms/rmsCompanyPosition/exportXls",
          importExcelUrl: "rms/rmsCompanyPosition/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'int',value:'positionType',text:'类型：1-普通职位，2-灵活用工，3-共享用工',dictCode:'position_type'})
        fieldList.push({type:'int',value:'ifParttime',text:'是否兼职：1-兼职，0-全职',dictCode:'if_parttime'})
        fieldList.push({type:'string',value:'companyId',text:'公司ID',dictCode:''})
        fieldList.push({type:'string',value:'postId',text:'名称ID',dictCode:''})
        fieldList.push({type:'string',value:'postName',text:'职位名称',dictCode:''})
        fieldList.push({type:'Text',value:'descr',text:'职位描述',dictCode:''})
        fieldList.push({type:'string',value:'addressName',text:'地址名称',dictCode:''})
        fieldList.push({type:'string',value:'addressHouse',text:'门牌号',dictCode:''})
        fieldList.push({type:'string',value:'address',text:'工作地点',dictCode:''})
        fieldList.push({type:'string',value:'longitude',text:'地点经度',dictCode:''})
        fieldList.push({type:'string',value:'latitude',text:'地点纬度',dictCode:''})
        fieldList.push({type:'string',value:'expRequire',text:'经验要求',dictCode:'exp_require'})
        fieldList.push({type:'string',value:'minEducation',text:'最低学历',dictCode:'education'})
        fieldList.push({type:'string',value:'salaryLow',text:'薪资范围',dictCode:''})
        fieldList.push({type:'string',value:'salaryUp',text:'薪资范围',dictCode:''})
        fieldList.push({type:'int',value:'salaryMonth',text:'薪资月份',dictCode:''})
        fieldList.push({type:'string',value:'salary',text:'薪资范围',dictCode:''})
        fieldList.push({type:'string',value:'unit',text:'薪资单位，兼职，元/时，元/天，元/周，元/月',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'unitMoney',text:'兼职，薪资单价',dictCode:''})
        fieldList.push({type:'string',value:'bonus',text:'奖金绩效',dictCode:''})
        fieldList.push({type:'int',value:'settlementType',text:'结算方式，兼职，日结、周结、月结、完工结',dictCode:''})
        fieldList.push({type:'int',value:'recruitsNumber',text:'招聘人数',dictCode:''})
        fieldList.push({type:'string',value:'partDate',text:'兼职工作日',dictCode:''})
        fieldList.push({type:'string',value:'partTime',text:'兼职时间',dictCode:''})
        fieldList.push({type:'string',value:'phone',text:'联系电话',dictCode:''})
        fieldList.push({type:'string',value:'skill',text:'技能要求',dictCode:''})
        fieldList.push({type:'date',value:'startDate',text:'开始日期'})
        fieldList.push({type:'date',value:'endDate',text:'结束日期'})
        fieldList.push({type:'int',value:'workDays',text:'工作天数',dictCode:''})
        fieldList.push({type:'int',value:'shareNumber',text:'共享人数',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'shareMoney',text:'分享佣金',dictCode:''})
        fieldList.push({type:'int',value:'browseNumber',text:'浏览数量',dictCode:''})
        fieldList.push({type:'string',value:'remark',text:'备注',dictCode:''})
        fieldList.push({type:'string',value:'city',text:'县级城市名称',dictCode:''})
        fieldList.push({type:'string',value:'citycode',text:'县级城市编码',dictCode:''})
        fieldList.push({type:'string',value:'pcity',text:'市级城市名称',dictCode:''})
        fieldList.push({type:'string',value:'pcitycode',text:'市级城市编码',dictCode:''})
        fieldList.push({type:'int',value:'tenantId',text:'tenantId',dictCode:''})
        fieldList.push({type:'int',value:'delFlag',text:'删除状态(0-正常,1-已删除)',dictCode:''})
        fieldList.push({type:'string',value:'status',text:'状态',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>